package com.itheima.web;

import com.itheima.pojo.User;
import com.itheima.service.UserService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/deleteUserByIDServlet")
public class DeleteUserByIDServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //拿到id
        Integer id = Integer.valueOf(request.getParameter("id"));


        //获得业务类对象
        UserService service = new UserService();

        //调用方法判断结果
        service.deleteUser(id);
        //跳转到删除成功页面
        response.sendRedirect("/delete_ok.jsp");

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
